package vashion.azeroth.core.service.impl.item;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vashion.azeroth.contant.AzerothConstants;
import vashion.azeroth.contant.ItemErrorEnum;
import vashion.azeroth.core.item.pojo.PropertyValueDO;
import vashion.azeroth.core.manager.forest.BaseForestPropertyManager;
import vashion.azeroth.core.manager.forest.BasePropertyValueManager;
import vashion.azeroth.core.result.ApiResult;
import vashion.azeroth.core.service.item.BrandService;

import java.util.List;

/**
 * 品牌接口查询
 * Created by liuhe on 15/10/4.
 */
@Service
public class BrandServiceImpl implements BrandService {

    private final static Logger log = LoggerFactory.getLogger(ItemSkuServiceImpl.class);

    @Autowired
    private BaseForestPropertyManager baseForestPropertyManager;

    @Autowired
    private BasePropertyValueManager basePropertyValueManager;

    //FIXME 这里类目似乎没有用到
    public ApiResult<List<PropertyValueDO>> getBrandList(Long categoryId, String brandName) {

        try {
            PropertyValueDO propertyValueDO = new PropertyValueDO();
            propertyValueDO.setPropertyMetaId(AzerothConstants.ItemConstant.brand_property_meta_id);
            propertyValueDO.setValue(brandName);
            List<PropertyValueDO> propertyValueDOList = basePropertyValueManager.find(propertyValueDO);
            return ApiResult.newSuccessResult(propertyValueDOList);
        } catch (Exception e) {
            log.error("BrandServiceImpl.getBrandList.error", e);
            return ApiResult.newErrorResult(ItemErrorEnum.SYSTEM_ERROR.getErrorCode(), ItemErrorEnum.SYSTEM_ERROR.getErrorMessage());
        }

    }
}
